package com.sangeng.service;

import com.sangeng.utils.SecurityUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName: PermissionService
 * Package: com.sangeng.service
 * Description:
 *
 * @Author hjh
 * @Create 2024/8/25 13:55
 * @Version 1.0
 */
@Service("ps")
public class PermissionService {
    public Boolean hasPermission(String permission){
        //如果是超级管理员 直接返回true
        if (SecurityUtils.isAdmin()){
            return true;
        }
        //否则 获取当前登录用户所具有的权限列表 如何判断 是否存在permission
        List<String> permissions = SecurityUtils.getLoginUser().getPermissions();
        return  permissions.contains(permission);
    }
}
